#pragma once

#include "..\Scrabble_Client\ClientSettings.h"

#include "PipeListener.h"
#include "Connection.h"
#include "Player.h"

class GameClient : public PipeListener
{
	Player mPlayer;
	Connection* mInConn;
	Connection* mOutConn;

	bool mIsConnected;
	bool mWantsToPlay;
	bool mIsPlaying;

	HANDLE mBagTileLockEvent;

	UINT mDraggedTileBagLine;
	UINT mDraggedTileBagCol;

	UINT mLineContributions[ClientSettings::BOARD_NLINES];

private:
	void ApplyLockPunishment();
	static DWORD WINAPI ControlTileBagLock(LPVOID param);

public:
	GameClient(Player _player, string _PclientPipeName);
	~GameClient(void);

public:	
	virtual bool HandleReceivedData(BYTE* _data);
	virtual Connection* GetInConnection();

	void ResetGameData();
	bool IsConnected() const;
	Player& GetPlayer();
	bool WantsToPlay() const { return mWantsToPlay; }
	void WantsToPlay(bool val) { mWantsToPlay = val; }
	void SendPipeMessage(PipeMessage& _msg);
	bool IsPlaying() const { return mIsPlaying; }
	void IsPlaying(bool val) { mIsPlaying = val; }
	UINT LineContributions(UINT _line) const { return mLineContributions[_line]; }

};

